<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

  <!--
    Cruisecontrol.NET dashboard xsl file for NSIS makensis.
    You must wrap the output of 'makensis' with 'execNSIS.pl'

    Jim Graham, Scimatic Software 29/01/2009
    Copyright (c) www.scimatic.com 29/01/2009

    MIT License

    Copyright (c) 2009 Scimatic Software Inc

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
  -->

  <xsl:output method="html"/>
  <xsl:variable name="nsis.root" select="//NSIS"/>

  <!-- Main template for the log -->
  <xsl:template match="/">
    <html>
      <head>
        <title>NSIS Installer Build Report</title>
      </head>
      <style>
        #Title {font-family: Verdana; font-size: 14pt; color: black; font-weight: bold}
        .ColumnHeader {font-family: Verdana; font-size: 8pt; background-color:white; color: black}
        .CriticalError {font-family: Verdana; font-size: 8pt; color: darkred; font-weight: bold; text-align: center}
        .Error {font-family: Verdana; font-size: 8pt; color: royalblue; font-weight: bold; text-align: center}
        .CriticalWarning {font-family: Verdana; font-size: 8pt; color: green; font-weight: bold; text-align: center}
        .Warning {font-family: Verdana; font-size: 8pt; color: darkgray; font-weight: bold; text-align: center}
        .Information {font-family: Verdana; font-size: 8pt; color: black; font-weight: bold; text-align: center}

        .PropertyName {font-family: Verdana; font-size: 8pt; color: black; font-weight: bold}
        .PropertyContent {font-family: Verdana; font-size: 8pt; color: black}
        .NodeIcon { font-family: WebDings; font-size: 12pt; color: navy; padding-right: 5;}
        .MessagesIcon { font-family: WebDings; font-size: 12pt; color: red;}
        .RuleDetails { padding-top: 10;}
        .SourceCode { background-color:#DDDDFF; }
        .RuleBlock { background-color:#EEEEFF; }
        .MessageNumber { font-family: Verdana; font-size: 10pt; color: darkred; }
        .MessageBlock { font-family: Verdana; font-size: 10pt; color: darkred; }
        .Resolution {font-family: Verdana; font-size: 8pt; color: black; }
        .NodeLine { font-family: Verdana; font-size: 9pt;}
        .Note { font-family: Verdana; font-size: 9pt; color:black; background-color: #DDDDFF; }
        .NoteUser { font-family: Verdana; font-size: 9pt; font-weight: bold; }
        .NoteTime { font-family: Verdana; font-size: 8pt; font-style: italic; }
        .Button { font-family: Verdana; font-size: 9pt; color: blue; background-color: #EEEEEE; }
      </style>
      <script>
        function ViewState(blockId)
        {
        var block = document.getElementById(blockId);
        if (block.style.display=='none')
        {
        block.style.display='block';
        }
        else
        {
        block.style.display='none';
        }
        }

        function SwitchAll(how)
        {
        var nodes = document.getElementsByTagName("div");
        for (i = 0; i != nodes.length;i++)
        {
        var block = nodes[i];
        if (block != null)
        {
        if (block.className == 'collapsable' )
        {
        block.style.display=how;
        }
        }
        }
        }

        function ExpandAll()
        {
        SwitchAll('block');
        }

        function CollapseAll()
        {
        SwitchAll('none');
        }
      </script>
      <body bgcolor="white" alink="Black" vlink="Black" link="Black">
        <xsl:apply-templates select="$nsis.root"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="NSIS">
    <!-- Report Title -->
    <div id="Title">
      MakeNSIS v<xsl:value-of select="@version"/> Build Log
    </div>
    <br/>

    <table>
      <tr>
        <td class="Button">
          <a href="#" onclick="javascript: ExpandAll();">Expand All</a>
        </td>
        <td class="Button">
          <a href="#" onclick="javascript: CollapseAll();">Collapse All</a>
        </td>
      </tr>
    </table>
    <br/>

    <!-- Process the steps -->
    <xsl:apply-templates select="//NSIS/Errors" />
    <xsl:apply-templates select="//NSIS/Configuration" />
    <xsl:apply-templates select="//NSIS/Processed" />
    <xsl:apply-templates select="//NSIS/Output" />
    <xsl:apply-templates select="//NSIS/Installer" />
  </xsl:template>

  <!-- Errors -->
  <xsl:template match="//NSIS/Errors">
    <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
      <tr>
        <td>
          <a href="#" onclick="javascript: ViewState('errors');">
            <span class="sectionheader">Errors</span>
          </a>
        </td>
      </tr>
    </table>
    <div class="collapsable" id="errors">
      <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
        <xsl:apply-templates select="//NSIS/Errors/Error" />
      </table>
    </div>

  </xsl:template>

  <xsl:template match="//NSIS/Errors/Error">
    <tr>
      <td colspan="2">
        <xsl:apply-templates />
      </td>
    </tr>
  </xsl:template>


  <!-- Configuration -->
  <xsl:template match="//NSIS/Configuration">
    <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
      <tr>
        <td>
          <a href="#" onclick="javascript: ViewState('configuration');">
            <span class="sectionheader">Configuration</span>
          </a>
        </td>
      </tr>
    </table>
    <div class="collapsable" id="configuration">
      <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
        <tr class="collapsable" id="configuration">
          <td>Plugin Directory:</td>
          <td>
            <xsl:value-of select="@plugins_dir"/>
          </td>
        </tr>
        <xsl:apply-templates select="//NSIS/Configuration/plugin" />
      </table>
    </div>

  </xsl:template>

  <xsl:template match="//NSIS/Configuration/plugin">
    <tr>
      <td colspan="2">
        <xsl:apply-templates />
      </td>
    </tr>
  </xsl:template>

  <!-- Processed -->
  <xsl:template match="//NSIS/Processed">
    <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
      <tr>
        <td colspan="2">
          <a href="#" onclick="javascript: ViewState('processed');">
            <span class="sectionheader">Processed 2</span>
          </a>
        </td>
      </tr>
    </table>
    <div class="collapsable" id="processed">
      <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
        <tr>
          <td>Script File:</td>
          <td>
            <xsl:value-of select="@script_file"/>
          </td>
        </tr>
      </table>
    </div>
  </xsl:template>

  <xsl:template match="//NSIS/Processed/script">
    <tr>
      <td colspan="2">
        <xsl:apply-templates select="script" />
      </td>
    </tr>
  </xsl:template>

  <!-- Output -->
  <xsl:template match="//NSIS/Output">
    <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
      <tr>
        <td colspan="2">
          <a href="#" onclick="javascript: ViewState('output');">
            <span class="sectionheader">Output</span>
          </a>
        </td>
      </tr>
    </table>
    <div class="collapsable" id="output">
      <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
        <tr>
          <td>Installer File:</td>
          <td>
            <xsl:value-of select="@installer_file"/>
          </td>
        </tr>

        <xsl:apply-templates select="//NSIS/Output/buildStep" />
      </table>
    </div>

  </xsl:template>

  <xsl:template match="//NSIS/Output/buildStep">
    <tr>
      <td>Step:</td>
      <td>
        <xsl:apply-templates />
      </td>
    </tr>
  </xsl:template>

  <!-- Installer -->
  <xsl:template match="//NSIS/Installer">
    <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
      <tr>
        <td colspan="2">
          <a href="#" onclick="javascript: ViewState('installer');">
            <span class="sectionheader">Installer</span>
          </a>
        </td>
      </tr>
    </table>
    <div class="collapsable" id="installer">
      <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
        <xsl:apply-templates select="//NSIS/Installer/installerInfo" />
      </table>
    </div>

  </xsl:template>

  <xsl:template match="//NSIS/Installer/installerInfo">
    <table class="section-table" cellSpacing="0" cellPadding="2" width="98%" border="0">
      <tr>
        <td>Info:</td>
        <td>
          <xsl:apply-templates />
        </td>
      </tr>
    </table>
  </xsl:template>


  <!-- Text template -->
  <xsl:template match="text()">
    <xsl:value-of select="." disable-output-escaping="yes" />
  </xsl:template>


</xsl:stylesheet>

<!--
    <tr><td class="sectionheader"><xsl:value-of select="@product"/> <xsl:value-of select="@version"/> Build Log</td></tr>
    <tr><td>Project File: <xsl:value-of select="@projectFile"/></td></tr>
    <tr><td>Build Started: <xsl:value-of select="@started"/></td></tr>

    <xsl:apply-templates select="//shfbBuild/buildStep" />

    <tr><td><a href="#" onclick="javascript: ExpandCollapseAll(false);">Collapse All</a><xsl:text disable-output-escaping="yes"><![CDATA[ &nbsp;&nbsp;&nbsp;&nbsp; ]]></xsl:text>
    <a href="#" onclick="javascript: ExpandCollapseAll(true);">Expand All</a></td></tr>

  </table>
</xsl:template>


 Build step template
<xsl:template match="//shfbBuild/buildStep">
-->